package com.github.ybq.android.spinkit.dialog;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

import com.github.ybq.android.spinkit.R;
import com.github.ybq.android.spinkit.R2;
import com.github.ybq.android.spinkit.titanic.Titanic;
import com.github.ybq.android.spinkit.titanic.TitanicTextView;
import com.github.ybq.android.spinkit.titanic.Typefaces;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * @author Administrator
 * @createTime 2019/9/28 13:36
 */
public class MyLoadingDialog extends DialogFragment {
    @BindView(R2.id.network_titanic_loading_view)
    TitanicTextView mLoadingView;
    private static Titanic mTitanic;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.network_dialog_titanic_loadingview, null);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mLoadingView.setTypeface(Typefaces.get(view.getContext(), "Satisfy-Regular.ttf"));
        mTitanic = new Titanic();
        mTitanic.start(mLoadingView);

    }

    public void stop() {
        mTitanic.cancel();
    }
}
